
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>2.2 使用 kubeadm 部署 · Kubernetes - 痴者工良</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="痴者工良">
        
        
    
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-insert-logo/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="3.kubeadm_ckad.html" />
    
    
    <link rel="prev" href="1.minikube.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.whuanle.cn" target="_blank" class="custom-link">痴者工良的博客</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    文档说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    1.基础知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../1.basic/">
            
                <a href="../1.basic/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../1.basic/1.docker.html">
            
                <a href="../1.basic/1.docker.html">
            
                    
                    1.1 说透 Docker：基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../1.basic/2.virtual.html">
            
                <a href="../1.basic/2.virtual.html">
            
                    
                    1.2 说透 Docker： 虚拟化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../1.basic/3.docker_network.html">
            
                <a href="../1.basic/3.docker_network.html">
            
                    
                    1.3 了解 Docker 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="../1.basic/4.pod_docker.html">
            
                <a href="../1.basic/4.pod_docker.html">
            
                    
                    1.4 Docker 和 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="../1.basic/5.k8s.html">
            
                <a href="../1.basic/5.k8s.html">
            
                    
                    1.5 K8S入门基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    2.部署和配置
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="2.deploy.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="1.minikube.html">
            
                <a href="1.minikube.html">
            
                    
                    2.1 使用 Minikube 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.3" data-path="2.kubeadm.html">
            
                <a href="2.kubeadm.html">
            
                    
                    2.2 使用 kubeadm 部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="3.kubeadm_ckad.html">
            
                <a href="3.kubeadm_ckad.html">
            
                    
                    2.3 CKAD认证中的部署教程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="4.kubeadm_proxy.html">
            
                <a href="4.kubeadm_proxy.html">
            
                    
                    2.4 国内代理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="5.dashboard.html">
            
                <a href="5.dashboard.html">
            
                    
                    2.5 Dashboard
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../3.pod/">
            
                <a href="../3.pod/">
            
                    
                    3.Pod部署和调度
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../3.pod/">
            
                <a href="../3.pod/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../3.pod/1.pod.html">
            
                <a href="../3.pod/1.pod.html">
            
                    
                    3.1 Pod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../3.pod/2.deployment.html">
            
                <a href="../3.pod/2.deployment.html">
            
                    
                    3.2 Deployment部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../3.pod/3.replica.html">
            
                <a href="../3.pod/3.replica.html">
            
                    
                    3.3 副本集(ReplicaSet)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../3.pod/4.pod_network.html">
            
                <a href="../3.pod/4.pod_network.html">
            
                    
                    3.34 Pod 端口映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../3.pod/5.update.html">
            
                <a href="../3.pod/5.update.html">
            
                    
                    3.5 Pod 升级、回滚
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../3.pod/6.scale.html">
            
                <a href="../3.pod/6.scale.html">
            
                    
                    3.6 Pod 缩放
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../3.pod/7.lable.html">
            
                <a href="../3.pod/7.lable.html">
            
                    
                    3.7.Pod 标签
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../3.pod/8.schedule.html">
            
                <a href="../3.pod/8.schedule.html">
            
                    
                    3.8 Pod 调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../3.pod/9.jobs_cronjobs.html">
            
                <a href="../3.pod/9.jobs_cronjobs.html">
            
                    
                    3.9 Jobs、CronJobs
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    4.Kubernetes 网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../4.network/">
            
                <a href="../4.network/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../4.network/1.network.html">
            
                <a href="../4.network/1.network.html">
            
                    
                    4.1 Kubernetes 网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../4.network/2.endpoint.html">
            
                <a href="../4.network/2.endpoint.html">
            
                    
                    4.2 Endpoint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../4.network/3.ingress.html">
            
                <a href="../4.network/3.ingress.html">
            
                    
                    4.3 ingress
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../4.network/4.discovery.html">
            
                <a href="../4.network/4.discovery.html">
            
                    
                    4.4 服务发现
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    5.volumes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../5.volumes/">
            
                <a href="../5.volumes/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../5.volumes/1.volumes.html">
            
                <a href="../5.volumes/1.volumes.html">
            
                    
                    5.1 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../5.volumes/2.secret_configmap.html">
            
                <a href="../5.volumes/2.secret_configmap.html">
            
                    
                    5.2 secret 和 ConfigMap 卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../5.volumes/3.nfts.html">
            
                <a href="../5.volumes/3.nfts.html">
            
                    
                    5.3 NFS卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../5.volumes/4.pv_pvc.html">
            
                <a href="../5.volumes/4.pv_pvc.html">
            
                    
                    5.4 持久化卷
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    6.API 和 安全
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../6.api_safe/">
            
                <a href="../6.api_safe/">
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../7.health/">
            
                <a href="../7.health/">
            
                    
                    7.维护和故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../8.health/README.md">
            
                <span>
            
                    
                    导读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../k8s.html">
            
                <a href="../k8s.html">
            
                    
                    Kubernetes 命令概览
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../ckad.html">
            
                <a href="../ckad.html">
            
                    
                    CKAD 认证帮助
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >2.2 使用 kubeadm 部署</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#22-&#x4F7F;&#x7528;-kubeadm-&#x90E8;&#x7F72;"><b></b>2.2 &#x4F7F;&#x7528; kubeadm &#x90E8;&#x7F72;</a></li><ul><ul><li><span class="title-icon "></span><a href="#&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;"><b></b>&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;</a></li></ul><li><span class="title-icon "></span><a href="#&#x5B89;&#x88C5;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;"><b></b>&#x5B89;&#x88C5;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;</a></li><ul><li><span class="title-icon "></span><a href="#&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;"><b></b>&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;</a></li><li><span class="title-icon "></span><a href="#&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;"><b></b>&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;</a></li></ul><li><span class="title-icon "></span><a href="#&#x96C6;&#x7FA4;&#x7BA1;&#x7406;"><b></b>&#x96C6;&#x7FA4;&#x7BA1;&#x7406;</a></li><ul><li><span class="title-icon "></span><a href="#&#x521B;&#x5EFA;-kubernetes-&#x96C6;&#x7FA4;"><b></b>&#x521B;&#x5EFA; kubernetes &#x96C6;&#x7FA4;</a></li><li><span class="title-icon "></span><a href="#&#x53EF;&#x80FD;&#x78B0;&#x5230;&#x7684;&#x95EE;&#x9898;"><b></b>&#x53EF;&#x80FD;&#x78B0;&#x5230;&#x7684;&#x95EE;&#x9898;</a></li><li><span class="title-icon "></span><a href="#&#x5220;&#x9664;&#x8282;&#x70B9;"><b></b>&#x5220;&#x9664;&#x8282;&#x70B9;</a></li><li><span class="title-icon "></span><a href="#&#x6E05;&#x9664;&#x73AF;&#x5883;"><b></b>&#x6E05;&#x9664;&#x73AF;&#x5883;</a></li></ul></ul></ul></div><h1 id="22-&#x4F7F;&#x7528;-kubeadm-&#x90E8;&#x7F72;"><a name="22-&#x4F7F;&#x7528;-kubeadm-&#x90E8;&#x7F72;" class="anchor-navigation-ex-anchor" href="#22-&#x4F7F;&#x7528;-kubeadm-&#x90E8;&#x7F72;"><i class="fa fa-link" aria-hidden="true"></i></a>2.2 &#x4F7F;&#x7528; kubeadm &#x90E8;&#x7F72;</h1>
<p>&#x4E0A;&#x4E00;&#x7AE0;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x7528; minikube &#x53BB;&#x642D;&#x5EFA;&#x5355;&#x673A;&#x96C6;&#x7FA4;&#xFF0C;&#x5E76;&#x4E14;&#x521B;&#x5EFA; Deployment&#x3001;Service(&#x5728;&#x4E09;&#x7AE0;&#x4E2D;&#x8BB2;&#x89E3;)&#xFF0C;&#x672C;&#x7BC7;&#x5C06;&#x4ECB;&#x7ECD;&#x5229;&#x7528; kubeadm &#x90E8;&#x7F72;&#x591A;&#x8282;&#x70B9;&#x96C6;&#x7FA4;&#xFF0C;&#x5E76;&#x5B66;&#x4F1A; &#x5B89;&#x88C5;&#x4EE5;&#x53CA;&#x4F7F;&#x7528; kubernetes &#x7684;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#xFF0C;&#x5FEB;&#x901F;&#x521B;&#x5EFA;&#x96C6;&#x7FA4;&#x5B9E;&#x4F8B;&#xFF0C;&#x5B8C;&#x6210;&#x90E8;&#x7F72; hello world &#x5E94;&#x7528;&#x7684;&#x5B9E;&#x8DF5;&#x3002;</p>
<p>Kubeadm &#x662F; CKAD &#x8BA4;&#x8BC1;&#x4E2D;&#x8981;&#x6C42;&#x638C;&#x63E1;&#x7684;&#x90E8;&#x7F72;&#x65B9;&#x5F0F;&#xFF0C;&#x4F46;&#x662F;&#x955C;&#x50CF;&#x9700;&#x8981;&#x56FD;&#x5916;&#x7F51;&#x7EDC;&#x624D;&#x80FD;&#x4E0B;&#x8F7D;&#xFF0C;&#x8BFB;&#x8005;&#x5982;&#x679C;&#x662F;&#x56FD;&#x5185;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x53EF;&#x4EE5;&#x53C2;&#x8003; 2.4 &#x7AE0;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x4F7F;&#x7528;&#x56FD;&#x5185;&#x670D;&#x52A1;&#x5668;&#x8FDB;&#x884C;&#x4EE3;&#x7406;&#x3002;</p>
<p>&#x672C;&#x7AE0;&#x5185;&#x5BB9;&#x4E3B;&#x8981;&#x4ECB;&#x7ECD;&#x5982;&#x4F55;&#x5B89;&#x88C5; kubeadm &#x4EE5;&#x53CA;&#x90E8;&#x7F72;&#x96C6;&#x7FA4;&#x3001;&#x6DFB;&#x52A0;&#x8282;&#x70B9;&#x3002;</p>
<p>&#x9700;&#x8981;&#x63D0;&#x524D;&#x5728;&#x670D;&#x52A1;&#x5668;&#x5B89;&#x88C5;&#x597D; Docker&#x3002;</p>
<h3 id="&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;"><a name="&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;" class="anchor-navigation-ex-anchor" href="#&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;</h3>
<p>&#x5728; kubernetes &#x4E2D;&#xFF0C;&#x4E3B;&#x8981;&#x6709;&#x4E09;&#x4E2A;&#x65E5;&#x5E38;&#x4F7F;&#x7528;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x8FD9;&#x4E9B;&#x5DE5;&#x5177;&#x4F7F;&#x7528; kube &#x524D;&#x7F00;&#x547D;&#x540D;&#xFF0C;&#x8FD9;&#x4E09;&#x4E2A;&#x5DE5;&#x5177;&#x5982;&#x4E0B;&#xFF1A;</p>
<ul>
<li><code>kubeadm</code>&#xFF1A;&#x7528;&#x6765;&#x521D;&#x59CB;&#x5316;&#x96C6;&#x7FA4;&#x7684;&#x6307;&#x4EE4;&#xFF0C;&#x80FD;&#x591F;&#x521B;&#x5EFA;&#x96C6;&#x7FA4;&#x5DF2;&#x7ECF;&#x6DFB;&#x52A0;&#x65B0;&#x7684;&#x8282;&#x70B9;&#x3002;&#x53EF;&#x7528;&#x5176;&#x5B83;&#x90E8;&#x7F72;&#x5DE5;&#x5177;&#x66FF;&#x4EE3;&#x3002;</li>
<li><code>kubelet</code>&#xFF1A;&#x5728;&#x96C6;&#x7FA4;&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x4E0A;&#x7528;&#x6765;&#x542F;&#x52A8; Pod &#x548C;&#x5BB9;&#x5668;&#x7B49;&#xFF0C;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x5FC5;&#x987B;&#x6709;&#xFF0C;&#x76F8;&#x5BF9;&#x4E8E;&#x8282;&#x70B9;&#x4E0E;&#x96C6;&#x7FA4;&#x7684;&#x7F51;&#x7EDC;&#x4EE3;&#x7406;&#x3002;</li>
<li><code>kubectl</code>&#xFF1A;&#x7528;&#x6765;&#x4E0E;&#x96C6;&#x7FA4;&#x901A;&#x4FE1;/&#x4EA4;&#x4E92;&#x7684;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#xFF0C;&#x4E0E; kubernetes API-Server &#x901A;&#x8BAF;&#xFF0C;&#x662F;&#x6211;&#x4EEC;&#x64CD;&#x4F5C;&#x96C6;&#x7FA4;&#x7684;&#x5BA2;&#x6237;&#x7AEF;&#x3002;</li>
</ul>
<p>&#x5728; 1.5 &#x7AE0;&#x4E2D;&#x4ECB;&#x7ECD;&#x8FC7; kubelet&#x3001;kubectl&#xFF0C;kubelet &#x8D1F;&#x8D23;&#x96C6;&#x7FA4;&#x4E2D;&#x8282;&#x70B9;&#x95F4;&#x7684;&#x901A;&#x8BAF;&#xFF0C;kubectl &#x4F9B;&#x7528;&#x6237;&#x8F93;&#x5165;&#x547D;&#x4EE4;&#x63A7;&#x5236;&#x96C6;&#x7FA4;&#xFF0C;&#x800C;&#x4E14; kubeadm &#x5219;&#x662F;&#x521B;&#x5EFA;&#x96C6;&#x7FA4;&#x3001;&#x6DFB;&#x52A0;&#x51CF;&#x5C11;&#x8282;&#x70B9;&#x7684;&#x5DE5;&#x5177;&#x3002;</p>
<h2 id="&#x5B89;&#x88C5;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;"><a name="&#x5B89;&#x88C5;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;" class="anchor-navigation-ex-anchor" href="#&#x5B89;&#x88C5;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5B89;&#x88C5;&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;</h2>
<p>&#x547D;&#x4EE4;&#x884C;&#x5DE5;&#x5177;&#x662F;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x90FD;&#x9700;&#x8981;&#x5B89;&#x88C5;&#x7684;&#xFF0C; kubectl&#x3001;kubelet &#x4E24;&#x4E2A;&#x662F;&#x5FC5;&#x9700;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x800C; kubeadm &#x5219;&#x53EF;&#x4EE5;&#x88AB;&#x4EE3;&#x66FF;&#x3002;kubeadm &#x662F; Kubenetes &#x5B98;&#x65B9;&#x63A8;&#x8350;&#x7684;&#x90E8;&#x7F72;&#x5DE5;&#x5177;&#xFF0C;&#x4F46;&#x7531;&#x4E8E;&#x7F51;&#x7EDC;&#x7B49;&#x5404;&#x65B9;&#x9762;&#x539F;&#x56E0;&#xFF0C;&#x4E2D;&#x6587;&#x793E;&#x533A;&#x4E2D;&#x4E5F;&#x5F00;&#x53D1;&#x4E86;&#x4E00;&#x4E9B;&#x66FF;&#x4EE3;&#x9879;&#x76EE;&#xFF0C;&#x4F8B;&#x5982; Kubesphere(<a href="https://kubesphere.com.cn" target="_blank">https://kubesphere.com.cn/</a>)&#xFF0C;&#x53EF;&#x5728;&#x56FD;&#x5185;&#x90E8;&#x7F72; Kubernetes&#xFF0C;&#x7701;&#x53BB;&#x7F51;&#x7EDC;&#x95EE;&#x9898;&#x3002;</p>
<h3 id="&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;"><a name="&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;" class="anchor-navigation-ex-anchor" href="#&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;</h3>
<p>&#x4E0B;&#x9762;&#x4ECB;&#x7ECD;&#x5982;&#x4F55; &#x901A;&#x8FC7; Google &#x7684;&#x6E90;&#x4E0B;&#x8F7D;&#x5B89;&#x88C5;&#x5DE5;&#x5177;&#x5305;&#x3002;</p>
<p>&#x66F4;&#x65B0; <code>apt</code> &#x5305;&#x7D22;&#x5F15;&#x5E76;&#x5B89;&#x88C5;&#x4F7F;&#x7528; Kubernetes <code>apt</code> &#x4ED3;&#x5E93;&#x6240;&#x9700;&#x8981;&#x7684;&#x5305;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">sudo</span> <span class="token function">apt-get</span> update
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> -y apt-transport-https ca-certificates <span class="token function">curl</span>
</code></pre>
<p>&#x4E0B;&#x8F7D; Google Cloud &#x516C;&#x5F00;&#x7B7E;&#x540D;&#x79D8;&#x94A5;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">sudo</span> <span class="token function">curl</span> -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
</code></pre>
<p>&#x6DFB;&#x52A0; Kubernetes <code>apt</code> &#x4ED3;&#x5E93;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token builtin class-name">echo</span> <span class="token string">&quot;deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main&quot;</span> <span class="token operator">|</span> <span class="token function">sudo</span> <span class="token function">tee</span> /etc/apt/sources.list.d/kubernetes.list
</code></pre>
<p>&#x6CE8;&#xFF1A;&#x5982;&#x679C;&#x662F;&#x56FD;&#x5185;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x8BF7;&#x5FFD;&#x7565;&#x4EE5;&#x4E0A;&#x4E24;&#x6B65;&#xFF0C;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x89E3;&#x51B3;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">apt-get</span> update <span class="token operator">&amp;&amp;</span> <span class="token function">apt-get</span> <span class="token function">install</span> -y apt-transport-https
<span class="token function">curl</span> https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg <span class="token operator">|</span> apt-key <span class="token function">add</span> - 
<span class="token function">cat</span> <span class="token operator">&lt;&lt;</span><span class="token string">EOF<span class="token bash punctuation"> <span class="token operator">&gt;</span>/etc/apt/sources.list.d/kubernetes.list</span>
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF</span>
</code></pre>
<p>&#x66F4;&#x65B0; <code>apt</code> &#x5305;&#x7D22;&#x5F15;&#xFF0C;&#x5B89;&#x88C5; kubelet&#x3001;kubeadm &#x548C; kubectl&#xFF0C;&#x5E76;&#x9501;&#x5B9A;&#x5176;&#x7248;&#x672C;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">sudo</span> <span class="token function">apt-get</span> update
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> -y kubelet kubeadm kubectl
<span class="token function">sudo</span> apt-mark hold kubelet kubeadm kubectl
</code></pre>
<p>&#x6267;&#x884C;&#x547D;&#x4EE4;&#x68C0;&#x67E5;&#x662F;&#x5426;&#x6B63;&#x5E38;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubeadm --help
</code></pre>
<h3 id="&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;"><a name="&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;" class="anchor-navigation-ex-anchor" href="#&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x4E0D;&#x540C;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;</h3>
<p>&#x53EA;&#x662F;&#x8FD9;&#x91CC;&#x4ECB;&#x7ECD;&#x4E00;&#x4E0B; ubuntu &#x548C; centos &#x4E0D;&#x540C;&#x7684;&#x5B89;&#x88C5;&#x65B9;&#x6CD5;&#xFF0C;&#x5DF2;&#x7ECF;&#x901A;&#x8FC7;&#x524D;&#x9762;&#x7684;&#x5B89;&#x88C5;&#x65B9;&#x6CD5;&#x5B89;&#x88C5;&#x597D;&#xFF0C;&#x5219;&#x4E0D;&#x9700;&#x8981;&#x7406;&#x4F1A;&#x8FD9;&#x4E00;&#x5C0F;&#x8282;&#x3002;</p>
<p>Ubuntu &#x548C; Debain &#x7B49;&#x7CFB;&#x7EDF;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">sudo</span> <span class="token function">apt-get</span> update <span class="token operator">&amp;&amp;</span> <span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> -y apt-transport-https gnupg2 <span class="token function">curl</span>
<span class="token function">curl</span> -s https://packages.cloud.google.com/apt/doc/apt-key.gpg <span class="token operator">|</span> <span class="token function">sudo</span> apt-key <span class="token function">add</span> -
<span class="token builtin class-name">echo</span> <span class="token string">&quot;deb https://apt.kubernetes.io/ kubernetes-xenial main&quot;</span> <span class="token operator">|</span> <span class="token function">sudo</span> <span class="token function">tee</span> -a /etc/apt/sources.list.d/kubernetes.list
<span class="token function">sudo</span> <span class="token function">apt-get</span> update
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> -y kubelet kubeadm kubectl
</code></pre>
<p>Centos&#x3001;RHEL &#x7B49;&#x7CFB;&#x7EDF;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x547D;&#x4EE4;&#x901A;&#x8FC7;&#x8F6F;&#x4EF6;&#x4ED3;&#x5E93;&#x5B89;&#x88C5;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">cat</span> <span class="token operator">&lt;&lt;</span><span class="token string">EOF<span class="token bash punctuation"> <span class="token operator">&gt;</span> /etc/yum.repos.d/kubernetes.repo</span>
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF</span>
yum <span class="token function">install</span> -y kubelet kubeadm kubectl
</code></pre>
<h2 id="&#x96C6;&#x7FA4;&#x7BA1;&#x7406;"><a name="&#x96C6;&#x7FA4;&#x7BA1;&#x7406;" class="anchor-navigation-ex-anchor" href="#&#x96C6;&#x7FA4;&#x7BA1;&#x7406;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x96C6;&#x7FA4;&#x7BA1;&#x7406;</h2>
<h3 id="&#x521B;&#x5EFA;-kubernetes-&#x96C6;&#x7FA4;"><a name="&#x521B;&#x5EFA;-kubernetes-&#x96C6;&#x7FA4;" class="anchor-navigation-ex-anchor" href="#&#x521B;&#x5EFA;-kubernetes-&#x96C6;&#x7FA4;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x521B;&#x5EFA; kubernetes &#x96C6;&#x7FA4;</h3>
<p>Kubeadm &#x662F;&#x4E00;&#x4E2A;&#x521B;&#x5EFA;&#x7BA1;&#x7406;&#x5DE5;&#x5177;&#xFF0C;&#x4E3B;&#x8981;&#x63D0;&#x4F9B;&#x4E86; <code>kubeadm init</code> &#x548C; <code>kubeadm join</code> &#x4E24;&#x4E2A;&#x547D;&#x4EE4;&#xFF0C;&#x4F5C;&#x4E3A;&#x521B;&#x5EFA; Kubernetes &#x96C6;&#x7FA4;&#x7684; &#x201C;&#x5FEB;&#x6377;&#x9014;&#x5F84;&#x201D; &#x7684;&#x6700;&#x4F73;&#x5B9E;&#x8DF5;&#x3002;</p>
<p>Kubernetes &#x96C6;&#x7FA4;&#x7531; Master &#x548C; Worker &#x4E24;&#x79CD;&#x8282;&#x70B9;&#x7EC4;&#x6210;&#xFF0C;Master &#x8282;&#x70B9;&#x8D1F;&#x8D23;&#x63A7;&#x5236;&#x96C6;&#x7FA4;&#x6240;&#x6709;&#x7684;&#x8282;&#x70B9;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x672C;&#x6559;&#x7A0B;&#x96C6;&#x7FA4;&#x4E2D;&#x7684;&#x8282;&#x70B9;&#x5E94;&#x5F53;&#x90FD;&#x662F;&#x5185;&#x7F51;&#x53EF;&#x4E92;&#x901A;&#x7684;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x8FD9;&#x4E9B;&#x670D;&#x52A1;&#x5668;&#x4E4B;&#x95F4;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5185;&#x7F51;&#x76F8;&#x4E92;&#x8BBF;&#x95EE;&#x3002;&#x5982;&#x679C;&#x662F;&#x670D;&#x52A1;&#x5668;&#x4E4B;&#x95F4;&#x901A;&#x8FC7;&#x516C;&#x7F51;&#x76F8;&#x4E92;&#x901A;&#x8BAF;&#x7684;&#xFF0C;&#x64CD;&#x4F5C;&#x65B9;&#x6CD5;&#x8BF7;&#x67E5;&#x8BE2;&#x5176;&#x5B83;&#x6559;&#x7A0B;&#x3002;</p>
<p><strong>1&#xFF0C;&#x521B;&#x5EFA; Master</strong></p>
<p>&#x6267;&#x884C; <code>hostname -i</code> &#x67E5;&#x770B;&#x6B64; node &#x7684; ip&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x521D;&#x59CB;&#x5316;&#x4E00;&#x4E2A; API Server &#x670D;&#x52A1;&#xFF0C;&#x7ED1;&#x5B9A;&#x5730;&#x5740;&#x4E3A; 192.168.0.8&#xFF08;&#x6309;&#x7167;&#x4F60;&#x7684;ip&#x6539;&#xFF09;&#x3002;&#x6B64;&#x6B65;&#x9AA4;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A; master &#x8282;&#x70B9;&#x3002;</p>
<p>&#x6CE8;&#xFF1A;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528; <code>kubeadm init</code>&#xFF0C;&#x5B83;&#x4F1A;&#x81EA;&#x52A8;&#x4F7F;&#x7528;&#x9ED8;&#x8BA4;&#x7F51;&#x7EDC;ip&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubeadm init
<span class="token comment"># &#x6216; kubeadm init --apiserver-advertise-address 192.168.0.8</span>
<span class="token comment"># &#x6216; kubeadm init --apiserver-advertise-address $(hostname -i)</span>
</code></pre>
<blockquote>
<p>&#x90E8;&#x7F72;&#x5931;&#x8D25;&#xFF0C;&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x4E0B;&#x9762;&#x4E24;&#x4E2A;&#x547D;&#x4EE4;&#xFF0C;&#x67E5;&#x770B;&#x5931;&#x8D25;&#x539F;&#x56E0;&#x3002;</p>
<pre class="language-"><code>systemctl status kubelet
journalctl -xeu kubelet
</code></pre><p>&#x5E38;&#x89C1;&#x4E0E; Docker &#x6709;&#x5173;&#x7684;&#x9519;&#x8BEF;&#x53EF;&#x53C2;&#x8003;&#xFF1A;
<a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker" target="_blank">https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker</a></p>
</blockquote>
<p>&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x4F1A;&#x63D0;&#x793A;&#x4E00;&#x4E9B;&#x4FE1;&#x606F;&#xFF0C;&#x5728;&#x63D0;&#x793A;&#x7684;&#x5185;&#x5BB9;&#x4E2D;&#x627E;&#x5230;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubeadm <span class="token function">join</span> <span class="token number">192.168</span>.0.8:6443 --token q25z3f.v5uo5bphvgxkjnmz <span class="token punctuation">\</span>
    --discovery-token-ca-cert-hash sha256:0496adc212112b5485d0ff12796f66b29237d066fbc1d4d2c5e45e6add501f64
</code></pre>
<p>&#x4FDD;&#x5B58;&#x8FD9;&#x6BB5;&#x4FE1;&#x606F;&#x4E0B;&#x6765;&#x5907;&#x7528;&#xFF0C;&#x540E;&#x9762;&#x52A0;&#x5165;&#x8282;&#x70B9;&#x65F6;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x5230;&#x3002;</p>
<p>&#x5982;&#x679C;&#x6709;&#x63D0;&#x793A; <code>Alternatively, if you are the root user, you can run:</code>&#x5219;&#x4F60;&#x8FD8;&#x9700;&#x8981;&#x6267;&#x884C;&#x4E0B;&#x9762;&#x7684;&#x547D;&#x4EE4;&#x3002;</p>
<pre class="language-"><code class="lang-bash"><span class="token builtin class-name">export</span> <span class="token assign-left variable">KUBECONFIG</span><span class="token operator">=</span>/etc/kubernetes/admin.conf
</code></pre>
<blockquote>
<p><strong>[Info] &#x63D0;&#x793A;</strong></p>
<p>admin.conf &#x662F;&#x8FDE;&#x63A5; Kubernetes &#x7684;&#x8BA4;&#x8BC1;&#x6587;&#x4EF6;&#xFF0C;&#x901A;&#x8FC7;&#x6B64;&#x6587;&#x4EF6;&#x624D;&#x80FD;&#x8FDE;&#x63A5;&#x5230; kubernetes&#xFF0C;kubectl &#x4E5F;&#x9700;&#x8981;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#xFF1B;&#x5728; Linux &#x4E2D;&#xFF0C;&#x4F7F;&#x7528; KUBECONFIG &#x73AF;&#x5883;&#x53D8;&#x91CF;&#x77E5;&#x9053;&#x8BA4;&#x8BC1;&#x6587;&#x4EF6;&#x7684;&#x6240;&#x5728;&#x3002;</p>
<p>Linux &#x4E2D;&#x6BCF;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x662F;&#x4E0D;&#x540C;&#x7684;&#xFF0C;&#x5982;&#x679C;&#x5207;&#x6362;&#x4E86;&#x7528;&#x6237;&#xFF0C;&#x5219;&#x4E5F;&#x9700;&#x8981;&#x8BBE;&#x7F6E; KUBECONFIG &#x73AF;&#x5883;&#x53D8;&#x91CF;&#xFF1B;&#x5982;&#x679C;&#x8981;&#x5728;&#x522B;&#x7684;&#x8282;&#x70B9;&#x4E0A;&#x8FDE;&#x63A5;&#x96C6;&#x7FA4;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x628A;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x590D;&#x5236;&#x8FC7;&#x53BB;&#x3002;</p>
</blockquote>
<p>&#x540E;&#x9762;&#x7684;&#x64CD;&#x4F5C;&#x90FD;&#x9700;&#x8981; admin.conf &#x6587;&#x4EF6;&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x62A5; <code>The connection to the server localhost:8080 was refused - did you specify the right host or port?</code> &#x3002;</p>
<p>&#x7531;&#x4E8E; <code>export</code> &#x7684;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#x4E0D;&#x80FD;&#x6301;&#x4E45;&#x5316;&#xFF0C;&#x8BF7;&#x6253;&#x5F00; <code>~/.bashrc</code> &#x6587;&#x4EF6;&#xFF0C;&#x628A;&#x8FD9;&#x4E2A;&#x547D;&#x4EE4;&#x52A0;&#x5230;&#x6587;&#x4EF6;&#x6700;&#x540E;&#x9762;&#x3002;</p>
<blockquote>
<p><strong>[Info] &#x63D0;&#x793A;</strong></p>
<p>&#x4E3A;&#x4E86;&#x4FDD;&#x62A4; /etc/kubernetes/admin.conf&#xFF0C;&#x907F;&#x514D;&#x76F4;&#x63A5;&#x6307;&#x5411;&#xFF0C;&#x5EFA;&#x8BAE;&#x6BCF;&#x4E2A;&#x7528;&#x6237;&#x590D;&#x5236;&#x4E00;&#x6B21;&#x6B64;&#x6587;&#x4EF6;&#x5230;&#x7528;&#x6237;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x5176;&#x547D;&#x4EE4;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash"><span class="token function">mkdir</span> -p <span class="token environment constant">$HOME</span>/.kube
<span class="token function">cp</span> -f /etc/kubernetes/admin.conf <span class="token environment constant">$HOME</span>/.kube/config
<span class="token function">chown</span> <span class="token variable"><span class="token variable">$(</span><span class="token function">id</span> -u<span class="token variable">)</span></span><span class="token builtin class-name">:</span><span class="token variable"><span class="token variable">$(</span><span class="token function">id</span> -g<span class="token variable">)</span></span> <span class="token environment constant">$HOME</span>/.kube/config
</code></pre>
</blockquote>
<p><strong>2&#xFF0C;&#x521D;&#x59CB;&#x5316;&#x7F51;&#x7EDC;</strong></p>
<p>&#x8FD9;&#x4E00;&#x6B65;&#x4E0D;&#x662F;&#x5FC5;&#x9700;&#x7684;&#xFF0C;&#x4E0D;&#x8FC7;&#x4E00;&#x822C;&#x6765;&#x8BF4;&#xFF0C;&#x90E8;&#x7F72; Kubernetes &#x4F1A;&#x914D;&#x7F6E;&#x7F51;&#x7EDC;&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x8282;&#x70B9;&#x4E4B;&#x95F4;&#x4E0D;&#x80FD;&#x76F8;&#x4E92;&#x8BBF;&#x95EE;&#xFF0C;&#x8BFB;&#x8005;&#x53EF;&#x4EE5;&#x8DDF;&#x7740;&#x505A;&#x4E00;&#x6B21;&#xFF0C;&#x5728;&#x540E;&#x9762;&#x7684;&#x7AE0;&#x8282;&#x4E2D;&#x6211;&#x4EEC;&#x5728;&#x4E00;&#x63A2;&#x7A76;&#x7ADF;&#x3002;</p>
<p>&#x901A;&#x8FC7;&#x8FDC;&#x7A0B;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x521D;&#x59CB;&#x5316;&#x7F51;&#x7EDC;&#xFF0C;&#x9700;&#x8981;&#x4ECE;&#x7B2C;&#x4E09;&#x65B9;&#x62C9;&#x53D6;&#x4E00;&#x4E2A; yaml &#x6587;&#x4EF6;&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl apply  -f  <span class="token string">&quot;https://cloud.weave.works/k8s/net?k8s-version=<span class="token variable"><span class="token variable">$(</span>kubectl version <span class="token operator">|</span> base64 <span class="token operator">|</span> <span class="token function">tr</span> -d <span class="token string">&apos;\n&apos;</span><span class="token variable">)</span></span>&quot;</span>  --namespace<span class="token operator">=</span>kube-system
<span class="token comment">#  --namespace=kube-system &#x8868;&#x793A;&#x63D2;&#x4EF6;&#x653E;&#x5230; kube-system &#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E2D;&#x8FD0;&#x884C;</span>
</code></pre>
<p>&#x6210;&#x529F;&#x7684;&#x8BDD;&#x4F1A;&#x63D0;&#x793A;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">serviceaccount/weave-net created
clusterrole.rbac.authorization.k8s.io/weave-net created
clusterrolebinding.rbac.authorization.k8s.io/weave-net created
role.rbac.authorization.k8s.io/weave-net created
rolebinding.rbac.authorization.k8s.io/weave-net created
daemonset.apps/weave-net created
</code></pre>
<p>&#x6211;&#x4EEC;&#x4E5F;&#x53EF;&#x4EE5;&#x624B;&#x52A8;&#x914D;&#x7F6E;&#xFF0C;&#x6267;&#x884C; <code>kubectl version</code> &#x67E5;&#x770B;&#x7248;&#x672C;&#x53F7;&#xFF0C;&#x627E;&#x5230; <code>GitVersion:v1.21.1</code> &#xFF0C;&#x66FF;&#x6362; yaml &#x6587;&#x4EF6;&#x7684;&#x5730;&#x5740; <code>https://cloud.weave.works/k8s/net?k8s-version=v1.21.1</code>&#xFF0C;&#x7136;&#x540E;&#x6267;&#x884C; <code>kubectl apply -n kube-system -f net.yaml</code> &#x5373;&#x53EF;&#x3002;</p>
<p><strong>3&#xFF0C;&#x52A0;&#x5165;&#x96C6;&#x7FA4;</strong></p>
<p>&#x524D;&#x9762;&#x5DF2;&#x7ECF;&#x521B;&#x5EFA;&#x4E86; Master &#x8282;&#x70B9;&#xFF0C;&#x63A5;&#x4E0B;&#x6765;&#x5C06;&#x53E6;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x4EE5; Worker &#x8282;&#x70B9;&#x7684;&#x65B9;&#x5F0F;&#x52A0;&#x5165;&#x96C6;&#x7FA4;&#x4E2D;&#x3002;&#x5982;&#x679C;&#x8BFB;&#x8005;&#x53EA;&#x6709;&#x4E00;&#x53F0;&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x5219;&#x53EF;&#x4EE5;&#x8DF3;&#x8FC7;&#x8FD9;&#x4E2A;&#x6B65;&#x9AA4;&#x3002;</p>
<p>&#x5F53;&#x8282;&#x70B9;&#x52A0;&#x5165; kubeadm &#x521D;&#x59CB;&#x5316;&#x7684;&#x96C6;&#x7FA4;&#x65F6;&#xFF0C;&#x53CC;&#x65B9;&#x9700;&#x8981;&#x5EFA;&#x7ACB;&#x53CC;&#x5411;&#x4FE1;&#x4EFB;&#xFF0C;&#x5206;&#x4E3A;&#x53D1;&#x73B0;(Worker&#x4FE1;&#x4EFB;Master) &#x548C; TLS &#x5F15;&#x5BFC;(Master&#x4FE1;&#x4EFB;&#x5F85;&#x52A0;&#x5165;Worker)&#x4E24;&#x90E8;&#x5206;&#x3002;&#x76EE;&#x524D;&#x6709;&#x4E24;&#x79CD;&#x52A0;&#x5165;&#x65B9;&#x5F0F;&#xFF0C;&#x4E00;&#x79CD;&#x662F;&#x901A;&#x8FC7;&#x4EE4;&#x724C;&#x52A0;&#x5165;&#xFF0C;&#x4E00;&#x79CD;&#x662F;&#x901A;&#x8FC7; kubeconfig &#x6587;&#x4EF6;&#x52A0;&#x5165;&#x3002;</p>
<p>&#x683C;&#x5F0F;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubeadm <span class="token function">join</span> --discovery-token abcdef.xxx <span class="token punctuation">{</span>IP<span class="token punctuation">}</span>:6443 --discovery-token-ca-cert-hash sha256:xxx
kubeadm join--discovery-file file.conf
</code></pre>
<p>&#x5728;&#x7B2C;&#x4E8C;&#x4E2A;&#x8282;&#x70B9;&#x4E2D;&#xFF0C;&#x4F7F;&#x7528;&#x4E4B;&#x524D;<strong><span style="color:red;">&#x5907;&#x4EFD;&#x597D;&#x7684;&#x547D;&#x4EE4;</span></strong>&#xFF0C;&#x76F4;&#x63A5;&#x6267;&#x884C;&#xFF0C;&#x52A0;&#x5165;&#x96C6;&#x7FA4;&#xFF0C;<strong><span style="color:red;">&#x683C;&#x5F0F;&#x5982;&#x4E0B;&#x547D;&#x4EE4;&#x6240;&#x793A;</span></strong>&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubeadm <span class="token function">join</span> <span class="token number">192.168</span>.0.8:6443 --token q25z3f.v5uo5bphvgxkjnmz <span class="token punctuation">\</span>
    --discovery-token-ca-cert-hash sha256:0496adc212112b5485d0ff12796f66b29237d066fbc1d4d2c5e45e6add501f64
</code></pre>
<p>&#x590D;&#x5236;&#x7C98;&#x8D34;&#x65F6;&#xFF0C;&#x8981;&#x6CE8;&#x610F;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x7531;&#x4E8E; <code>\</code> &#x6362;&#x884C;&#x7B26;&#xFF0C;&#x5BFC;&#x81F4;&#x7C98;&#x8D34;&#x65F6;&#xFF0C;&#x591A;&#x4E86;&#x4E00;&#x4E2A;&#x5C0F;&#x6570;&#x70B9;&#xFF0C;&#x5BFC;&#x81F4;&#x62A5;&#x9519;&#x3002;</p>
<p><img src="images/&#x7C98;&#x8D34;&#x51FA;&#x9519;.png" alt="&#x7C98;&#x8D34;&#x51FA;&#x9519;"></p>
<h3 id="&#x53EF;&#x80FD;&#x78B0;&#x5230;&#x7684;&#x95EE;&#x9898;"><a name="&#x53EF;&#x80FD;&#x78B0;&#x5230;&#x7684;&#x95EE;&#x9898;" class="anchor-navigation-ex-anchor" href="#&#x53EF;&#x80FD;&#x78B0;&#x5230;&#x7684;&#x95EE;&#x9898;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x53EF;&#x80FD;&#x78B0;&#x5230;&#x7684;&#x95EE;&#x9898;</h3>
<p>&#x67E5;&#x770B; docker &#x7248;&#x672C;&#xFF1A;<code>yum list installed | grep docker</code> &#x548C; <code>docker version</code>&#x3002;</p>
<p>&#x5982;&#x679C;&#x90E8;&#x7F72;&#x8FC7;&#x7A0B;&#x4E2D;&#x51FA;&#x73B0; <code>failed to parse kernel config: unable to load kernel module</code>&#xFF0C;&#x4E5F;&#x8BF4;&#x660E;&#x4E86; docker &#x7248;&#x672C;&#x592A;&#x9AD8;&#xFF0C;&#x9700;&#x8981;&#x964D;&#x7EA7;&#x3002;</p>
<p>&#x5982;&#x679C;&#x670D;&#x52A1;&#x5668;&#x88C5;&#x4E86; dnf&#xFF0C;&#x90A3;&#x4E48;&#x964D;&#x7EA7; docker &#x7248;&#x672C;&#x7684;&#x547D;&#x4EE4;&#xFF1A;</p>
<pre class="language-"><code>dnf remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
</code></pre><pre class="language-"><code>dnf -y install dnf-plugins-core
</code></pre><pre class="language-"><code>dnf install docker-ce-18.06.3.ce-3.el7 docker-ce-cli containerd.io
</code></pre><p>&#x4E0D;&#x884C;&#x7684;&#x8BDD;&#x5C31;&#x6309;&#x7167; <a href="https://docs.docker.com/engine/install/centos/" target="_blank">https://docs.docker.com/engine/install/centos/</a> &#x964D;&#x7EA7;&#xFF0C;&#x6216;&#x8005;&#x81EA;&#x884C;&#x6309;&#x7167;&#x5176;&#x5B83;&#x65B9;&#x6CD5;&#x5904;&#x7406;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF0C;<code>docker version</code> &#x4F1A;&#x770B;&#x5230; client &#x548C; server &#x7248;&#x672C;&#xFF0C;&#x4E24;&#x8005;&#x7684;&#x7248;&#x672C;&#x53F7;&#x53EF;&#x80FD;&#x4E0D;&#x4E00;&#x81F4;&#x3002;</p>
<h3 id="&#x5220;&#x9664;&#x8282;&#x70B9;"><a name="&#x5220;&#x9664;&#x8282;&#x70B9;" class="anchor-navigation-ex-anchor" href="#&#x5220;&#x9664;&#x8282;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5220;&#x9664;&#x8282;&#x70B9;</h3>
<p>&#x5728;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x4E2D;&#xFF0C;&#x7531;&#x4E8E;&#x8282;&#x70B9;&#x4E0A;&#x5DF2;&#x7ECF;&#x90E8;&#x7F72;&#x7740;&#x670D;&#x52A1;&#xFF0C;&#x56E0;&#x6B64;&#x76F4;&#x63A5;&#x5220;&#x9664;&#x8282;&#x70B9;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x5BFC;&#x81F4;&#x4E25;&#x91CD;&#x7684;&#x6545;&#x969C;&#x95EE;&#x9898;&#x3002;&#x56E0;&#x6B64;&#x9700;&#x8981;&#x79FB;&#x9664;&#x4E00;&#x4E2A;&#x8282;&#x70B9;&#x65F6;&#xFF0C;&#x9996;&#x5148;&#x8981;&#x5728;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x9A71;&#x9010;&#x6240;&#x6709; Pods&#xFF0C;Kubernetes &#x4F1A;&#x81EA;&#x52A8;&#x5C06;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x7684; Pod &#x8F6C;&#x79FB;&#x5230;&#x5176;&#x5B83;&#x8282;&#x70B9;&#x4E0A;&#x90E8;&#x7F72;(&#x7B2C;&#x4E09;&#x7AE0;&#x4F1A;&#x8BB2;)&#x3002;</p>
<p>&#x83B7;&#x53D6;&#x96C6;&#x7FA4;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x8282;&#x70B9;&#xFF0C;&#x627E;&#x5230;&#x9700;&#x8981;&#x9A71;&#x9010;&#x7684;&#x8282;&#x70B9;&#x540D;&#x79F0;&#x3002;</p>
<pre class="language-"><code class="lang-bash">kubectl get nodes
</code></pre>
<p>&#x9A71;&#x9010;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x6240;&#x6709;&#x7684; Pod&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl drain <span class="token punctuation">{</span>node&#x540D;&#x79F0;<span class="token punctuation">}</span>
</code></pre>
<p>&#x867D;&#x7136;&#x9A71;&#x9010;&#x4E86;&#x8282;&#x70B9;&#x4E0A;&#x6240;&#x6709;&#x7684;&#x670D;&#x52A1;&#xFF0C;&#x4F46;&#x662F;&#x8282;&#x70B9;&#x4F9D;&#x7136;&#x5728;&#x96C6;&#x7FA4;&#x4E2D;&#xFF0C;&#x53EA;&#x662F; Kubernetes &#x4E0D;&#x4F1A;&#x518D;&#x90E8;&#x7F72; Pod &#x5230;&#x6B64;&#x8282;&#x70B9;&#x4E0A;&#x3002;&#x5982;&#x679C;&#x9700;&#x8981;&#x6062;&#x590D;&#x6B64;&#x8282;&#x70B9;&#xFF0C;&#x5141;&#x8BB8;&#x7EE7;&#x7EED;&#x90E8;&#x7F72; Pod&#xFF0C;&#x53EF;&#x4F7F;&#x7528;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl uncordon <span class="token punctuation">{</span>&#x8282;&#x70B9;&#x540D;&#x79F0;<span class="token punctuation">}</span>
</code></pre>
<p>&#x5173;&#x4E8E;&#x9A71;&#x9010;&#xFF0C;&#x540E;&#x9762;&#x7684;&#x7AE0;&#x8282;&#x4F1A;&#x5B66;&#x4E60;&#x5230;&#x3002;</p>
<p>&#x6CE8;&#xFF1A;&#x9A71;&#x9010; Pod&#xFF0C;&#x5E76;&#x4E00;&#x5B9A;&#x80FD;&#x591F;&#x9A71;&#x9010;&#x6240;&#x6709; Pod&#xFF0C;&#x6709;&#x4E9B; Pod &#x53EF;&#x80FD;&#x4E0D;&#x4F1A;&#x88AB;&#x6E05;&#x9664;&#x3002;</p>
<p>&#x6700;&#x7EC8;&#x5220;&#x9664;&#x6B64;&#x8282;&#x70B9;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubectl delete node <span class="token punctuation">{</span>&#x8282;&#x70B9;&#x540D;&#x79F0;<span class="token punctuation">}</span>
</code></pre>
<p>&#x96C6;&#x7FA4;&#x5220;&#x9664;&#x4E86;&#x6B64;&#x8282;&#x70B9;&#x540E;&#xFF0C;&#x8282;&#x70B9;&#x4E0A;&#x8FD8;&#x4FDD;&#x7559;&#x7740;&#x4E00;&#x4E9B;&#x6570;&#x636E;&#xFF0C;&#x53EF;&#x4EE5;&#x7EE7;&#x7EED;&#x6E05;&#x9664;&#x73AF;&#x5883;&#x3002;</p>
<h3 id="&#x6E05;&#x9664;&#x73AF;&#x5883;"><a name="&#x6E05;&#x9664;&#x73AF;&#x5883;" class="anchor-navigation-ex-anchor" href="#&#x6E05;&#x9664;&#x73AF;&#x5883;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x6E05;&#x9664;&#x73AF;&#x5883;</h3>
<p>&#x5982;&#x679C;&#x6B65;&#x9AA4;&#x505A;&#x9519;&#x4E86;&#x60F3;&#x91CD;&#x6765;&#xFF0C;&#x6216;&#x8005;&#x79FB;&#x9664;&#x8282;&#x70B9;&#x9700;&#x8981;&#x6E05;&#x9664;&#x73AF;&#x5883;&#xFF0C;&#x53EF;&#x4EE5;&#x6267;&#x884C; <code>kubeadm reset [flags]</code> &#x547D;&#x4EE4;&#x3002;</p>
<p>&#x6CE8;&#xFF1A;&#x53EA;&#x6267;&#x884C; <code>kubeadm reset</code> &#x547D;&#x4EE4;&#x65E0;&#x6548;&#x3002;</p>
<p><code>[flags]</code> &#x6709;&#x56DB;&#x79CD;&#x7C7B;&#x578B;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">preflight              Run reset pre-flight checks
update-cluster-status  Remove this node from the ClusterStatus object.
remove-etcd-member     Remove a <span class="token builtin class-name">local</span> etcd member.
cleanup-node           Run cleanup node.
</code></pre>
<p>&#x6211;&#x4EEC;&#x9700;&#x8981;&#x6267;&#x884C;&#xFF1A;</p>
<pre class="language-"><code class="lang-bash">kubeadm reset cleanup-node 
kubeadm reset
</code></pre>
<p>&#x5373;&#x53EF;&#x5728;&#x5F53;&#x524D;&#x670D;&#x52A1;&#x5668;&#x4E0A;&#x6E05;&#x9664; Kubernetes &#x6B8B;&#x7559;&#x7684; &#x5BB9;&#x5668;&#x6216;&#x8005;&#x5176;&#x5B83;&#x6570;&#x636E;&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; &#x75F4;&#x8005;&#x5DE5;&#x826F; 2021 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x6587;&#x6863;&#x6700;&#x540E;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2021-11-17 07:17:28
</span></footer>
<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="1.minikube.html" class="navigation navigation-prev " aria-label="Previous page: 2.1 使用 Minikube 部署">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="3.kubeadm_ckad.html" class="navigation navigation-next " aria-label="Next page: 2.3 CKAD认证中的部署教程">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"2.2 使用 kubeadm 部署","level":"1.3.3","depth":2,"next":{"title":"2.3 CKAD认证中的部署教程","level":"1.3.4","depth":2,"path":"2.deploy/3.kubeadm_ckad.md","ref":"2.deploy/3.kubeadm_ckad.md","articles":[]},"previous":{"title":"2.1 使用 Minikube 部署","level":"1.3.2","depth":2,"path":"2.deploy/1.minikube.md","ref":"2.deploy/1.minikube.md","articles":[]},"dir":"ltr"},"config":{"plugins":["tbfed-pagefooter","anchor-navigation-ex","mermaid-gb3","insert-logo","chapter-fold","advanced-emoji","github","splitter","alerts","popup","prism","-highlight","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy 痴者工良 2021","modify_label":"文档最后更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"prism":{"lang":{"flow":"typescript","shell":"bash"},"ignore":["mermaid","eval-js"],"css":["prismjs/themes/prism.css"],"js":["prismjs/prism.js","prismjs/components.js","prismjs/components/prism-go.min.js","prismjs/components/prism-yaml.min.js","prismjs/components/prism-bash.min.js","prismjs/components/prism-shell-session.min.js"]},"github":{"url":"https://github.com/whuanle/kubernetes"},"livereload":{},"splitter":{},"search":{},"popup":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"mermaid-gb3":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":false,"showLevel":false},"alerts":{},"advanced-emoji":{"embedEmojis":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"insert-logo":{"style":"background: none; max-height: 50px; min-height: 50px","url":"/images/logo.jpg"}},"theme":"default","author":"痴者工良","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Kubernetes - 痴者工良","language":"zh-hans","links":{"sidebar":{"痴者工良的博客":"https://www.whuanle.cn"}},"gitbook":"*","description":"这是一本关于 Kubernetes 的书，作者 痴者工良"},"file":{"path":"2.deploy/2.kubeadm.md","mtime":"2021-11-16T23:17:28.185Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-11-16T23:21:22.294Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-insert-logo/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

